package com.yang.sso.oauth.enums;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 自定义响应码
 *
 * @author haoxr
 * @since 2020-06-23
 **/
@AllArgsConstructor
@NoArgsConstructor
public enum ResultCode implements IResultCode, Serializable {

    /**
     * 授权
     */
    SUCCESS(200,"成功"),
    LOGIN_SUCCESS(1,"登录成功"),

    FAIL(400,"失败"),
    LOGIN_FAIL(0,"登录失败"),

    USERNAME_OR_PASSWORD_ERROR(400, "用户名或密码错误"),
    PASSWORD_ENTER_EXCEED_LIMIT(400, "用户输入密码次数超限"),
    CLIENT_AUTHENTICATION_FAILED(400, "客户端认证失败"),
    TOKEN_INVALID(401, "token无效或已过期"),
    TOKEN_ACCESS_FORBIDDEN(401, "token已被禁止访问"),

    AUTHORIZED_ERROR(401, "访问权限异常"),
    ACCESS_UNAUTHORIZED(401, "访问未授权"),

    ;

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    private Integer code;

    private String message;

    @Override
    public String toString() {
        return "{" +
                "\"code\":\"" + code + '\"' +
                ", \"msg\":\"" + message + '\"' +
                '}';
    }

}
